<?php
/**
 * Created by PhpStorm.
 * User: wangsong
 * Time: 2018/5/30 10:32
 */

namespace App\Transformers\Auxiliary;

use App\Models\Auxiliary\AuxiliaryCheckEntry;
use League\Fractal\TransformerAbstract;

class AuxiliaryCheckEntryTransformer extends TransformerAbstract
{
    protected $translate;

    public function __construct()
    {
        $this->translate = config('custom.auxiliary.translate');
    }

    /**
     * @param \App\Models\Auxiliary\AuxiliaryCheckEntry $entry
     * @return array
     */
    public function transform(AuxiliaryCheckEntry $entry)
    {
        return [
            'id'         => $entry->id,
            'record_id'  => $entry->record_id,
//            'images'     => collect($entry->images)->map(function ($image) {
//                return url($image);
//            })->toArray(),
            'images'     => $entry->images,
            'remark'     => $entry->remark,
            'check_type' => $entry->check_type,
            'check_name' => $this->translate[$entry->check_type],
            'created_at' => $entry->created_at->toDateTimeString(),
            'updated_at' => $entry->updated_at->toDateTimeString(),
        ];
    }
}